//
//  RefreshView.swift
//  VVbo
//
//  Created by Mr.Run on 2017/9/4.
//  Copyright © 2017年 Mr.Run. All rights reserved.
//

import UIKit

class RefreshView: UIView {

    var refreshState:RefreshState = .Normal {
        didSet{
            
            switch refreshState {
            case .Normal:
                tipLabel?.text = "继续使劲拉..."
                tipIcon?.isHidden = false
                indicator?.stopAnimating()
                UIView.animate(withDuration: 0.25, animations: {
                    self.tipIcon?.transform = CGAffineTransform.identity
                })
            case .Pulling:
                tipLabel?.text = "放手就刷新..."
                
                UIView.animate(withDuration: 0.25, animations: {
                    self.tipIcon?.transform = CGAffineTransform(rotationAngle:.pi*0.99)
                })
                
            case .WillRefresh:
                tipLabel?.text = "正在刷新中..."
                tipIcon?.isHidden = true
                indicator?.startAnimating()
                
                
                
            }
            
        }
    }
    
    var parentViewHeight:CGFloat = 0
    
    @IBOutlet weak var tipIcon: UIImageView?

    @IBOutlet weak var tipLabel: UILabel?
    
    @IBOutlet weak var indicator: UIActivityIndicatorView?
    
    class func refreshView()-> RefreshView {
        
        let nib = UINib(nibName: "RefreshMeiTuanView", bundle: nil)
        return nib.instantiate(withOwner: nil, options: nil)[0] as! RefreshView
        
    }
    
}
